package day07.zero;

import java.util.Random;

/**
 * 说明:
 *
 * @author: luohaowei
 * @date:2023/2/20
 *  验证码
 **/
public class VerificationCode {
    public static void main(String[] args) {
        String code=generateVeriCode(4);
        System.out.println("验证码"+code);
    }
    public static String generateVeriCode(int len){
        String code="";
        char[] chs ={'a','s','d','f','g','h','j','k','l','q','w','e','r','t','y','u','i',
                'o','p','z','x','c','v','b','n','m','A','S','D','F','G','H','J','K','L','Q',
                'W','E','R','T','Y','U','I','O','P','Z','X','C','V','B','N','M','1','2',
                '3','4','5','6','7','8','9'};
        Random rand=new Random();
        for(int i=1;i<=len;i++){
            //int index=(int)(Math.random()*chs.length);
           int index=rand.nextInt(chs.length);
            code+=chs[index];
        }
        return code;
    }
    /*
    String code=generateVeriCode(4);
        System.out.println("验证码"+code);
    }
    public static String generateVeriCode(int len){
        String code="";
        char[] chs ={'a','s','d','f','g','h','j','k','l','q','w','e','r','t','y','u','i',
                'o','p','z','x','c','v','b','n','m','A','S','D','F','G','H','J','K','L','Q',
                'W','E','R','T','Y','U','I','O','P','Z','X','C','V','B','N','M','1','2',
                '3','4','5','6','7','8','9'};
        Random rand=new Random();
        for(int i=1;i<=len;i++){
            //int index=(int)(Math.random()*chs.length);
           int index=rand.nextInt(chs.length);
            code+=chs[index];
        }
        return code;
     */
}




